package org.example.student_system.aop;

import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.stereotype.Component;

@Aspect
@Component
@Slf4j
public class Aop {

    @Around("@annotation(ao)")
    public Object method(ProceedingJoinPoint jp, anno ao) throws Throwable{
        double start = System.nanoTime();
        Object result = jp.proceed();
        double end = System.nanoTime();
        log.info("{}耗时：{}秒", jp.toShortString(), (end - start)/1e9);
        return result;
    }
}
